import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    isCollapse: false,              // 侧边栏菜单折叠状态
    searchCollapse: false,          // 高级搜索条件折叠状态
    // 发薪模块的数据
    payrollData: [
      {
        "serial": "1",
        "staffName": "王小虎A",
        "clientJobNumber": "A1234567",
        "bank": "中国建设银行",
        "idNumber": "441522199901011752",
        "cardNo": "441522199901011752",
        "financialAccount": "46545656",
        "mobile": "13131111131",
        "staffState": "正式"
      },
      {
        "serial": "2",
        "staffName": "王小虎B",
        "clientJobNumber": "A1234567",
        "bank": "中国建设银行",
        "idNumber": "441522199901011752",
        "cardNo": "154646515616516515",
        "financialAccount": "46545656",
        "mobile": "13244223150",
        "staffState": "正式"
      },
      {
        "serial": "3",
        "staffName": "王小虎C",
        "clientJobNumber": "A1234567",
        "bank": "中国建设银行",
        "idNumber": "441522199901011752",
        "cardNo": "154646515616516515",
        "financialAccount": "46545656",
        "mobile": "13244223150",
        "staffState": "正式"
      },
      {
        "serial": "4",
        "staffName": "王小虎D",
        "clientJobNumber": "A1234567",
        "bank": "中国建设银行",
        "idNumber": "441522199901011752",
        "cardNo": "154646515616516515",
        "financialAccount": "46545656",
        "mobile": "13244223150",
        "staffState": "正式"
      },
      {
        "serial": "5",
        "staffName": "王小虎E",
        "clientJobNumber": "A1234567",
        "bank": "中国建设银行",
        "idNumber": "441522199901011752",
        "cardNo": "154646515616516515",
        "financialAccount": "46545656",
        "mobile": "13244223150",
        "staffState": "正式"
      }
    ],
    modify: [],                      //发薪模块编辑的数据
    payrollIndex: 0,                 // 发薪模块点击对象的索引
    ruleForm:[],   //角色编辑的数据
    // 法人公司列表数据
    companyIndex: 0,
    companyTableData: [
        {
            "id": 1,
            "companyNo": "C100000001",
            "companyName": "深圳市某某有限公司",
            "legalPerson": "王林林",
            "foundationDate": "2016-05-02",
            "registeredType": "有限责任公司",
            "employees": "45",
            "registeredAddress": "上海市普陀区金沙江路 1518 弄",
            "businessTerm": "不限",
            "status": true,
            "serviceArea": "华南地区",
            "superiorCompany": "北京分公司",
            "idCard": "440307199909090099",
            "idCardDate": ["2021-04-28", "2021-05-09"],
            "startDate": "2021-05-05",
            "leaseAddress": "深圳市南山区",
            "money": "500",
            "creditCode": "4403071999",
            "businessImg": "",
            "licenceProgress": "办理中",
            "businessScope": "计算机设备、办公用品",
            "remark": "备注"
        },
        {
            "id": 2,
            "companyNo": "C100000002",
            "companyName": "广州市某某有限公司",
            "legalPerson": "张木木",
            "foundationDate": "2019-02-02",
            "registeredType": "有限责任公司",
            "employees": "100",
            "registeredAddress": "上海市普陀区金沙江路 1518 弄",
            "businessTerm": "5年",
            "status": false,
            "serviceArea": "华南地区",
            "superiorCompany": "北京分公司",
            "idCard": "440307199909090099",
            "idCardDate": ["2021-04-28", "2021-05-07"],
            "startDate": "2021-05-05",
            "leaseAddress": "深圳市南山区",
            "money": "500",
            "creditCode": "4403071999",
            "businessImg": "",
            "licenceProgress": "办理中",
            "businessScope": "计算机设备、办公用品",
            "remark": "备注"
        },
        {
            "id": 3,
            "companyNo": "C100000003",
            "companyName": "北京某某有限公司",
            "legalPerson": "陈陈",
            "foundationDate": "2020-08-01",
            "registeredType": "有限责任公司",
            "employees": "230",
            "registeredAddress": "上海市普陀区金沙江路 1518 弄",
            "businessTerm": "10年",
            "status": false,
            "serviceArea": "华南地区",
            "superiorCompany": "北京分公司",
            "idCard": "440307199909090099",
            "idCardDate": ["2021-04-28", "2021-05-07"],
            "startDate": "2021-05-05",
            "leaseAddress": "深圳市南山区",
            "money": "500",
            "creditCode": "4403071999",
            "businessImg": "",
            "licenceProgress": "办理中",
            "businessScope": "计算机设备、办公用品",
            "remark": "备注"
        }
    ],
      //角色账号列表数据
      roleAccountTableData: [
          {
              "sortNum": "1",
              "name": "王琳琳",
              "userAccount": "橘子哒哒",
              "functionRange": "全部权限",
              "idCard": "451236547894123564",
              "roleNum": "010052",
              "roleName": "部门经理",
              "telPhone": "17312345343",
              "updateDate": "2016-05-04",
              "updateAuthor": "张三",
              "buseinerrArea": "营销运营部",
              "status": false,
              "address": "上海市普陀区金沙江路 1518 弄"
          },
          {
              "sortNum": "2",
              "updateDate": "2016-05-04",
              "idCard": "566666666663478945",
              "roleNum": "032567",
              "roleName": "人力资源部",
              "functionRange": "开放全部组织管理权限、仅开放员工管理的员工信息、入职办理、转正办理的权限",
              "telPhone": "13856412456",
              "userAccount": "中奖了",
              "name": "王小虎",
              "updateAuthor": "胶己人",
              "buseinerrArea": "总经办",
              "status": false,
              "address": "上海市普陀区金沙江路 1517 弄"
          },
          {
              "sortNum": "3",
              "updateDate": "2016-05-01",
              "idCard": "336666666666142547",
              "telPhone": "15965234568",
              "roleNum": "032567",
              "roleName": "人力资源部",
              "functionRange": "开放全部组织管理权限、仅开放员工管理的员工信息、入职办理、转正办理的权限",
              "buseinerrArea": "营销运营部",
              "userAccount": "逗你玩",
              "name": "张三疯",
              "updateAuthor": "李四",
              "status": false,
              "address": "上海市普陀区金沙江路 1519 弄"
          },
          {
              "sortNum": "4",
              "updateDate": "2016-05-03",
              "idCard": "3456231457894561235",
              "telPhone": "18845623589",
              "name": "Allen",
              "roleNum": "010041",
              "roleName": "部门经理",
              "functionRange": "全部权限",
              "updateAuthor": "小老弟",
              "userAccount": "OrangeDaDa",
              "buseinerrArea": "总经办",
              "status": true,
              "address": "上海市普陀区金沙江路 1516 弄"
          }
      ]
  },
  mutations: {
    // 改变侧边栏菜单折叠状态
    changeCollapse(state) {
      state.isCollapse = !state.isCollapse
    },
    // 改变高级搜索条件折叠状态
    changeSearchCollapse(state, value) {
      state.searchCollapse = value;
    },
    // 发薪模块请求的数据存进state
    payrollFn(state, res) {
      state.payrollData = res
    },
    // 修改payrollIndex索引
    payrollIndexFn(state, res) {
      state.payrollIndex = res;
    },
    // 添加数据
    addData(state, param) {
      state.payrollData.push(param)
    },
    // 修改数据
    modifyData(state, param) {
      state.modify = param
      console.log(state.modify);
    },
    // 保存数据
    preserve(state) {
      state.payrollData[state.payrollIndex] = state.modify
      console.log(state.payrollData[state.payrollIndex]);
    },
    // 改变法人公司当前编辑数据索引
    changeCompanyIndex(state, index) {
      state.companyIndex = index;
    },
    // 修改编辑角色的数据
    changeRuleForm(state,param){
      //编辑角色的数据等于传进来的数据
      state.ruleForm = param;
    },
    //修改ruleForm的里面的functionRange值
    changeRole(state,param){
      state.ruleForm.functionRange = param[0];
      state.ruleForm.roleName = param[1];
    },
  },
  actions: {}
});

export { store }
